<template>
  <div class="gx">
    <el-carousel :interval="4000" type="card" height="250px">
      <el-carousel-item v-for="item in banner" :key="item.tragetId">
        <img v-lazy="item.imageUrl" alt="" style="width: 480px; height: 250px" />
      </el-carousel-item>
    </el-carousel>

    <div class="songOrder">
      <h3>推荐歌单 <i class="el-icon-arrow-right"></i></h3>
      <ul>
        <li v-for="i in tuijian" :key="i.id" @click="togd(i.id)">
          <div>
            <span class="track"
              ><i class="el-icon-caret-right"></i>
              {{ getPlayCount(i.playCount) }}</span
            >
            <img v-lazy="i.picUrl" alt="" />
          </div>
          <div class="name">
            {{i.name}}
          </div>
        </li>
      </ul>
    </div>
    <div class="release">
      <h3>独家放送 <i class="el-icon-arrow-right"></i></h3>
      <div class="release_video">
        <ul>
          <li v-for="i in dujia" :key="i.id">
            <div><img v-lazy="i.picUrl" alt=""></div>
            <div class="name">{{i.name}}</div>
          </li>
          
        </ul>
      </div>
    </div>
    <div class="latest">
      <h3>最新音乐 <i class="el-icon-arrow-right"></i></h3>
      <ul>
        <li v-for="i in zuixin" :key="i.id" @click="sentId(i.id)">
          <div><img v-lazy="i.picUrl" alt=""></div>
          <div class="name"><p>{{i.name}}<span>{{i.song.alias[0]==null? '':'('+i.song.alias[0]+')'}}</span></p><span @click.stop="toArtist(i.song.artists[0].id)" class="author">{{i.song.artists[0].name}}</span></div>
        </li>
      
      </ul>
    </div>
    <div class="release">
      <h3>推荐MV <i class="el-icon-arrow-right"></i></h3>
      <div class="mv">
        <ul>
          <li v-for="i in MV" :key="i.id" @click="toVideo(i.id)">
            <div>
              <img v-lazy="i.picUrl" alt="">
            </div>
            <div class="name">{{i.name}}</div>
            <span class="author" @click.stop="toArtist(i.artistId)">{{i.artistName}}</span>
          </li>
        
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      banner: [],
      tuijian: [],
      dujia:[],
      zuixin:[],
      MV:[],
      
    };
  },
  methods:{
    togd(id){
      this.$router.push({name:'songlist',query:{id:id}})
    },
    toArtist(id){
      this.$router.push({name:'zhuanji',query:{id:id}})
    },
    sentId(id){
      this.$store.state.mid=id
      this.$emit('getId')
    },
     toVideo(id){
         
          this.$router.push({name:'playVideo',query:{vid:id}})
        
      }
  },
  mounted() {
    this.$request({
      url: "/banner?type=0",
    }).then((success) => {
      this.banner = success.data.banners;
    });
    this.$request({
      url: "/personalized?limit=10",
      withCredentials: true, 
    }).then((success) => {
      this.tuijian = success.data.result;
    });
    this.$request({
      url:'/personalized/privatecontent',
    }).then(success=>{
      this.dujia=success.data.result
    
    });
    this.$request({
      url:"/personalized/newsong",
    }).then(success=>{
      this.zuixin=success.data.result
     
  
    });
    this.$request({
      url:'/personalized/mv'
    }).then(success=>{
      this.MV=success.data.result
    
    })
  },
  computed: {
    getPlayCount() {
      return function (count) {
        if (count >= 10000) {
          count = parseInt(count / 10000);
          return count + "万";
        } else {
          return count;
        }
      };
    },
  },
};
</script>

<style scoped>
img {
  border-radius: 10px;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.songOrder ul {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.songOrder ul li {
  position: relative;
  margin-top: 20px;
  height:230px;
  width: 170px;
  overflow: hidden;
  border-radius: 10px;
}
.name{
  padding: 10px 0;
 
}
.track {
  position: absolute;
  right: 10px;
  display: inline-block;
  height: 30px;
  line-height: 30px;
  color: white;
  font-size: 14px;
}
.songOrder ul li img {
  width: 170px;
}
.release {
  margin-top: 40px;
}
.release_video ul {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
}
.release_video ul li {
  width: 300px;
  height: 150px;
  border-radius: 10px;
}
.release_video ul li img{
 width: 300px;
}
.latest {
  margin-top: 40px;
}
.latest ul li img{
  width: 60px;
  margin-right: 10px;
}
.latest ul {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 20px;
}
.latest ul li {
  display: flex;
  margin-bottom: 20px;
  width: 300px;
  height: 60px;
  border-radius: 10px;
  cursor: pointer;
}
.latest ul li:hover{
  background-color: #F6F6F7;
}
.latest ul li span{
  color: gray;
  font-size: 14px;
  
}
.mv{
  margin-top: 20px;
}
.mv ul {
  display: flex;
  justify-content: space-between;
}
.mv ul li{
  width: 220px;
}

.mv ul li img{
  width: 220px;
  height:124px ;
}
.author{
  font-size: 14px;
  color: gray;
}
.author:hover{
  color: #475669;
}
</style>